package hust.music.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import hust.music.dao.UserDao;
import hust.music.domain.User;
import hust.music.service.UserService;

@Service("userService")
public class UserServiceImpl implements UserService {

	@Autowired
	private UserDao userDao;

	@Override
	@Transactional
	public boolean register(User user) {
		if (!userDao.isUserExist(user.getUsername())) {
			userDao.save(user);
			return true;
		}
		return false;
	}

	@Override
	@Transactional
	public User login(User user) {
		return userDao.login(user);
	}

}
